//
//  HEOrderPayCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/10/28.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEOrderPayCell.h"
#import "HEServerComfireModel.h"

@interface HEOrderPayCell ()

@property(nonatomic, strong) UILabel *titleLb;
@property(nonatomic, strong) UIImageView *iconImgView;
@property (nonatomic, strong) UIImageView *selectBtn;

@end

@implementation HEOrderPayCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
     if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
         self.backgroundColor = [UIColor clearColor];
         self.selectionStyle = UITableViewCellSelectionStyleNone;
          [self initUI];
     }
     return self;;
 }

- (void)initUI {
    
    _iconImgView = [UIImageView new];
    _iconImgView.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:_iconImgView];
    
    _titleLb = [UILabel new];
    _titleLb.font = DYBlodFont(16);
    _titleLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview:_titleLb];
    
    // 勾选
    _selectBtn = [UIImageView new];
    _selectBtn.image = IMAGE_NAMED(@"check_box_unsel");
    [self.contentView addSubview:_selectBtn];

    [_iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.width.mas_offset(38);
        make.height.mas_offset(38);
        make.top.equalTo(self.contentView).mas_offset(15);
        make.bottom.equalTo(self.contentView).mas_offset(-15);
    }];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(_iconImgView.mas_right).mas_offset(10);
        make.right.equalTo(_selectBtn.mas_left).mas_offset(10);
     }];
    
    [_selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.width.height.mas_offset(25);
    }];
}

- (void)selectPayTypeClick {
    
}

- (void)configCellWithModel:(HEServerComfireModel *)model fiterModel:(GDFiterCellModel *)fiterModel indexPath:(NSIndexPath *)indexPath {
    HEPaymentModel *payModel = model.orderPayments[indexPath.row];
    
    _iconImgView.image = IMAGE_NAMED(@"pay_wx");
     [_iconImgView sd_setImageWithURL:[NSURL URLWithString:payModel.icon] placeholderImage:nil];
     _titleLb.text = payModel.name;

    if (payModel.isChoose) {
      _selectBtn.image = IMAGE_NAMED(@"check_box_sel");
    }else {
      _selectBtn.image = IMAGE_NAMED(@"check_box_unsel");
    }
}

- (void)refreshContent:(GDFiterCellModel *)fiterModel formModel:(GDFormModel *)formModel indexPath:(NSIndexPath *)indexPath {
    
    HEPaymentModel *payModel = formModel.order_payments[indexPath.row];
    
    _iconImgView.image = IMAGE_NAMED(@"pay_wx");
     [_iconImgView sd_setImageWithURL:[NSURL URLWithString:payModel.icon] placeholderImage:nil];
     _titleLb.text = payModel.name;

    if (payModel.isChoose) {
      _selectBtn.image = IMAGE_NAMED(@"check_box_sel");
    }else {
      _selectBtn.image = IMAGE_NAMED(@"check_box_unsel");
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
